package com.apinji.alipay;

import com.apinji.alipay.dto.AlipayCloseDto;
import com.apinji.alipay.dto.AlipayRefundDto;
import com.apinji.alipay.dto.AlipayRefundQueryDto;
import com.apinji.alipay.service.AlipayCloseService;
import com.apinji.alipay.service.AlipayRefundService;
import com.apinji.common.domain.wrapper.Reply;
import com.apinji.common.plugin.Mutual;
import com.apinji.common.plugin.StrUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.regex.Pattern;

/**
 * 支付宝网站支付，退款
 *
 */
@RestController
@EnableAutoConfiguration
@EnableAsync
@RequestMapping("/v1.0/alipay")
public class AlipayCloseController {
    @Autowired
    private AlipayCloseService alipayCloseService;

    /**
     * 支付宝网站退款
     *
     * @param alipayCloseDto
     * @return
     */
    @RequestMapping(value = "/close")
    public Reply refund(@RequestBody AlipayCloseDto alipayCloseDto) throws Exception{
        if(StrUtils.isEmpty(alipayCloseDto.getUserUUID())) {
            return Mutual.invalidParamAppend("userUUID");
        }
        if(StrUtils.isEmpty(alipayCloseDto.getId())) {
            return Mutual.invalidParamAppend("id");
        }
        //
        return alipayCloseService.close(alipayCloseDto);
    }



}
